package com.ss.android.article.base.feature.message;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.view.ViewPager;
import android.view.View;

import com.ss.android.account.Spipe;
import com.ss.android.article.base.ui.MessageTabLineView;
import com.ss.android.article.base.ui.x;
import com.ss.android.article.browser.R;
import com.ss.android.common.ui.view.SwipeOverlayFrameLayout;
import com.ss.android.common.util.ToolUtils;
import com.ss.android.messagebus.Subscriber;
import com.ss.android.messagebus.SubscriptionRouter;
import com.ss.android.newmedia.activity.FragmentActivity;

public class MessageTabActvity extends FragmentActivity {
    public static final class a {
        public int a;

        public a(int arg1) {

            this.a = arg1;
        }
    }

    ViewPager a;
    f[] b;
    MessageTabIndicator[] c;
    private String d;
    private boolean e;
    private MessageTabLineView f;
    private View.OnClickListener g;

    public MessageTabActvity() {

        this.d = "";
        this.e = false;
        this.b = new f[3];
        this.c = new MessageTabIndicator[3];
        this.g = new com.ss.android.article.base.feature.message.a(this);
    }

    private static f a(int arg4, String arg5, boolean arg6) {
        Bundle v0 = new Bundle();
        v0.putLong("user_id", 0);
        v0.putInt("update_type", arg4);
        v0.putBoolean("from_mine", arg6);
        if(arg5 != null) {
            v0.putString("sub_msg_type", arg5);
        }

        f v1 = new f();
        v1.setArguments(v0);
        return v1;
    }

    static SwipeOverlayFrameLayout a(MessageTabActvity arg1) {
        return arg1.mSwipeOverlay;
    }

    public static void a(Context arg1, String arg2) {
        arg1.startActivity(MessageTabActvity.b(arg1, arg2));
    }

    private void a(MessageTabIndicator arg3, int arg4, int arg5) {
        arg3.a.setText(this.getString(arg5));
        View.OnClickListener v0 = this.g;
        arg3.setTag(Integer.valueOf(arg4));
        arg3.setOnClickListener(v0);
    }

    public static Intent b(Context arg3, String arg4) {
        Intent v0 = new Intent(arg3, MessageTabActvity.class);
        v0.putExtra("from_mine", false);
        v0.putExtra("update_message_type", arg4);
        return v0;
    }

    public int getDayBackgroundRes() {
        return R.color.i6;
    }

    public int getLayout() {
        return R.layout.fm;
    }

    public int getNightBackgroundRes() {
        return R.color.xi;
    }

    public void init() {
        int v3 = 4;
        int v5 = 2;
        super.init();
        SubscriptionRouter.addSubscriber(this);
        Intent v0 = this.getIntent();
        if(v0 != null) {
            this.e = v0.getBooleanExtra("from_mine", false);
            this.d = v0.getStringExtra("update_message_type");
        }

        if(android.support.design.a.isTextEmpty(this.d)) {
            this.d = "default";
        }

        this.b[0] = MessageTabActvity.a(v3, "comment", this.e);
        this.b[1] = MessageTabActvity.a(v3, "digg", this.e);
        this.b[v5] = MessageTabActvity.a(5, null, this.e);
        this.f = (MessageTabLineView) this.findViewById(R.id.a2l);
        this.findViewById(com.ss.android.article.browser.R.id.divide_line);
        this.a = (ViewPager) this.findViewById(R.id.view_pager);
        this.a.setOffscreenPageLimit(v5);
        this.a.setAdapter(new b(this, this.getSupportFragmentManager()));
        this.a.addOnPageChangeListener(new x(this.f));
        this.c[0] = (MessageTabIndicator) this.findViewById(R.id.a2j);
        this.a(this.c[0], 0, R.string.update_comment);
        this.c[1] = (MessageTabIndicator) this.findViewById(R.id.a2i);
        this.a(this.c[1], 1, R.string.update_digg);
        this.c[v5] = (MessageTabIndicator) this.findViewById(R.id.a2k);
        this.a(this.c[v5], v5, R.string.system_notify);
        this.a.addOnPageChangeListener(new c(this));
        if(!android.support.design.a.isTextEmpty(this.d)) {
            if("reply".equals(this.d)) {
                this.a.setCurrentItem(0);
            }
            else if("digg".equals(this.d)) {
                this.a.setCurrentItem(1);
            }
            else if("notify".equals(this.d)) {
                this.a.setCurrentItem(v5);
            }
        }

        if(!Spipe.inst().isLogin) {
            Bundle v0_1 = android.support.design.a.createJumpData("title_default", "other");
            Spipe.inst();
            Spipe.a(((Activity)this), v0_1);
        }
    }

    public void onBackPressed() {
        if(!this.isFinishing()) {
            Intent v0 = null;
            if(this.isTaskRoot()) {
                v0 = ToolUtils.getLaunchIntentForPackage(((Context)this), this.getPackageName());
            }

            this.finish();
            if(v0 == null) {
                return;
            }

            this.startActivity(v0);
        }
    }

    @Subscriber public void onClearTipEvent(a arg3) {
        if(this.a != null && this.a.getCurrentItem() == arg3.a) {
            this.c[arg3.a].setTipNumber(0);
        }
    }

    public void onDestroy() {
        super.onDestroy();
        SubscriptionRouter.removeSubscriber(this);
    }

    public void onResume() {
        super.onResume();
    }
}

